import { defineConfig } from '@vben/vite-config';
import path from 'path';
import ElementPlus from 'unplugin-element-plus/vite';
import vue from '@vitejs/plugin-vue';
import copy from 'rollup-plugin-copy';

export default defineConfig(async () => {
  return {
    application: {},
    plugins: [
      vue(),
      copy({
        targets: [
          {
            src: 'node_modules/@liveqing/liveplayer-v3/dist/component/liveplayer-lib.min.js',
            dest: 'public/js',
          },
        ],
      }),
    ],
    vite: {
      plugins: [
        ElementPlus({
          format: 'esm',
        }),
      ],
      resolve: {
        alias: {
          '#': path.resolve(__dirname, './src'),
          // 其他已有别名...
        },
      },
      server: {
        proxy: {
          '/api': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ''),
            // mock代理目标地址
            target:
              // 'http://192.168.0.23:80/api',//周 网线版
              // 'http://192.168.209.23:80/api',//周 wifi版
              'http://fs-smile.nbiot.muguasoft.com:7602/api',
            // 'http://fs-zhou.nbiot.muguasoft.com:7602/api',
            // ws: true,
          },
        },
      },
    },
  };
});
